package com.magic.gre.entity;

import com.magic.gre.helper.Contract;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: Lmoumou
 * Date: 2019-01-08 19:20
 * 文件名: AnswerBean
 * 描述:
 */
public class AnswerBean {
    /**
     * id : 1080407668318298117
     * updateTime : null
     * createTime : null
     * name : abate
     * symbol : [əˈbeɪt]
     * pronunciation : null
     * meaning : v. to become weaker 减弱
     * status : 1
     * thesaurusId : null
     * sameWord : null
     * example : The doctor gave him some medicine to abate the pain. 那医生给他一些药以减轻痛苦。
     * thesaurusName : null
     * unitName : null
     * userName : null
     * subItems : [{"id":"1082159871311822849","updateTime":"2019-01-07 14:19:53","createTime":"2019-01-07 14:19:53","subjectId":"1080407668318298117","itemName":"错误选项一","isRight":0,"isValid":1},{"id":"1082159871446040578","updateTime":"2019-01-07 14:19:53","createTime":"2019-01-07 14:19:53","subjectId":"1080407668318298117","itemName":"错误选项二","isRight":0,"isValid":1},{"id":"1082159871576064001","updateTime":"2019-01-07 14:19:53","createTime":"2019-01-07 14:19:53","subjectId":"1080407668318298117","itemName":"错误选项三","isRight":0,"isValid":1},{"id":"1082159871706087425","updateTime":"2019-01-07 14:19:53","createTime":"2019-01-07 14:19:53","subjectId":"1080407668318298117","itemName":"正确选项5","isRight":1,"isValid":1}]
     */
    private boolean isAnswer;//是否已回答过
    private String id;
    private Object updateTime;
    private Object createTime;
    private String name;
    private String symbol;
    private Object pronunciation;
    private String meaning;
    private int status;
    private String thesaurusId;
    private String sameWord;
    private String example;
    private Object thesaurusName;
    private Object unitName;
    private Object userName;
    private int unriped;
    private List<AnswerItemBean> subItems;
    private List<String> meanings;

    public int getUnriped() {
        return unriped;
    }

    public void setUnriped(int unriped) {
        this.unriped = unriped;
    }

    public boolean isAnswer() {
        return isAnswer;
    }

    public void setAnswer(boolean answer) {
        isAnswer = answer;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Object getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Object updateTime) {
        this.updateTime = updateTime;
    }

    public Object getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Object createTime) {
        this.createTime = createTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public Object getPronunciation() {
        return pronunciation;
    }

    public void setPronunciation(Object pronunciation) {
        this.pronunciation = pronunciation;
    }

    public String getMeaning() {
        return meaning;
    }

    public void setMeaning(String meaning) {
        this.meaning = meaning;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getThesaurusId() {
        return thesaurusId;
    }

    public void setThesaurusId(String thesaurusId) {
        this.thesaurusId = thesaurusId;
    }

    public String getSameWord() {
        return sameWord;
    }

    public void setSameWord(String sameWord) {
        this.sameWord = sameWord;
    }

    public String getExample() {
        return example;
    }

    public void setExample(String example) {
        this.example = example;
    }

    public Object getThesaurusName() {
        return thesaurusName;
    }

    public void setThesaurusName(Object thesaurusName) {
        this.thesaurusName = thesaurusName;
    }

    public Object getUnitName() {
        return unitName;
    }

    public void setUnitName(Object unitName) {
        this.unitName = unitName;
    }

    public Object getUserName() {
        return userName;
    }

    public void setUserName(Object userName) {
        this.userName = userName;
    }

    public List<AnswerItemBean> getSubItems() {
        return subItems;
    }

    public void setSubItems(List<AnswerItemBean> subItems) {
        this.subItems = subItems;
    }

    public List<MeanBean> getMeanings() {
        List<MeanBean> list = new ArrayList<>();
        if (meanings != null && !meanings.isEmpty()) {
            for (String str : meanings) {
                MeanBean meanBean = new MeanBean();
                if (str.contains(Contract.WORDS_N)) {
                    meanBean.setName(Contract.WORDS_N);
                    meanBean.setContent(str.substring(Contract.WORDS_N.length()));
                } else if (str.contains(Contract.WORDS_PRON)) {
                    meanBean.setName(Contract.WORDS_PRON);
                    meanBean.setContent(str.substring(Contract.WORDS_PRON.length()));
                } else if (str.contains(Contract.WORDS_ADJ)) {
                    meanBean.setName(Contract.WORDS_ADJ);
                    meanBean.setContent(str.substring(Contract.WORDS_ADJ.length()));
                } else if (str.contains(Contract.WORDS_ADV)) {
                    meanBean.setName(Contract.WORDS_ADV);
                    meanBean.setContent(str.substring(Contract.WORDS_ADV.length()));
                } else if (str.contains(Contract.WORDS_V)) {
                    meanBean.setName(Contract.WORDS_V);
                    meanBean.setContent(str.substring(Contract.WORDS_V.length()));
                } else if (str.contains(Contract.WORDS_NUM)) {
                    meanBean.setName(Contract.WORDS_NUM);
                    meanBean.setContent(str.substring(Contract.WORDS_ART.length()));
                } else if (str.contains(Contract.WORDS_ART)) {
                    meanBean.setName(Contract.WORDS_ART);
                    meanBean.setContent(str.substring(Contract.WORDS_NUM.length()));
                } else if (str.contains(Contract.WORDS_PREP)) {
                    meanBean.setName(Contract.WORDS_PREP);
                    meanBean.setContent(str.substring(Contract.WORDS_PREP.length()));
                } else if (str.contains(Contract.WORDS_CONJ)) {
                    meanBean.setName(Contract.WORDS_CONJ);
                    meanBean.setContent(str.substring(Contract.WORDS_CONJ.length()));
                } else if (str.contains(Contract.WORDS_INTERJ)) {
                    meanBean.setName(Contract.WORDS_INTERJ);
                    meanBean.setContent(str.substring(Contract.WORDS_INTERJ.length()));
                }

                list.add(meanBean);
            }
        }

        //添加同义词
        MeanBean sameBean = new MeanBean();
        sameBean.setName("同义词.");
        sameBean.setContent(sameWord);
        list.add(sameBean);

        //添加例句
        MeanBean exampleBean = new MeanBean();
        exampleBean.setName("例.");
        exampleBean.setContent(example);
        list.add(exampleBean);

        return list;
    }

    public void setMeanings(List<String> meanings) {
        this.meanings = meanings;
    }

    public String getVoicePath(String dirPath) {
        return dirPath + "/" + "wordaudio" + "/" + name + ".mp3";
    }

}
